//
//  MBPoiSearchSession.h
//  iNaviCore
//
//  Created by fanyunlong on 5/17/16.
//  Copyright © 2016 Mapbar. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MBWmrBaseTypes.h"
#import "MBPoiBaseTypes.h"
#import "MBNaviCoreBase.h"
#import "MBExpandView.h"
#import "MBEngine.h"


typedef void (^MBPoiSearchSessionBasicBlock)(void);
typedef void (^MBPoiSearchSessionErrorBlock)(MBPoiSearchError err, NSString* detail);
/**
 *  搜索成功结束的回调 block
 *
 *  @param pois              MBPoiItem
 *  @param corrections       MBCorrectionItem
 *  @param cityDistributions MBCityDistributionItem
 *  @param citySuggestions   MBCitySuggestionItem
 *  @param districts         MBDistrict
 */
typedef void (^MBPoiSearchSessionDataBlock)(NSArray *pois, NSArray *corrections, NSArray *cityDistributions, NSArray *citySuggestions, NSArray *districts);

@interface MBPoiSearchSession : NSObject

/**
 The shared default instance of `MBPoiSearchSession` initialized with default values.
 */
+ (instancetype)defaultInstance;
/**
 *  授权判断
 */
@property(nonatomic,readonly) MBSdkAuthError authErrorType;

@property (nonatomic, retain) NSString* defaultUrlBase;

@property (nonatomic, retain) NSString* urlBase;

@property (nonatomic, retain) NSString* keyword;

@property (nonatomic, assign) NSInteger pageSize;

@property (nonatomic, assign) NSInteger test;

// 设置搜索模式，在线，离线，在线优先，离线优先，默认仅在线
@property (nonatomic, assign) MBDataPreference preference;

@property (nonatomic, assign) NSInteger range;

/**
 *  设置查询点坐标, 在执行具体查询函数前必须设置。
 *
 *  @since 5.2.x
 */
@property (nonatomic, assign) MBPoint center;

@property (nonatomic, assign) BOOL isNearBy;

/**
 *  Get/Set search parameter city name.
 */
@property (nonatomic, retain) NSString* city;

- (void)setStartedBlock:(MBPoiSearchSessionBasicBlock)aStartedBlock;
- (void)setEndedBlock:(MBPoiSearchSessionBasicBlock)aEndBlock;
- (void)setFailedBlock:(MBPoiSearchSessionErrorBlock)aFailedBlock;
- (void)setLoadedBlock:(MBPoiSearchSessionDataBlock)aLoadedBlock;
- (void)setCanceledBlock:(MBPoiSearchSessionBasicBlock)aCancelBlock;

- (void)query;
-(void)cancelQuery;
/**
 *  每次加载的新数据信息是之前已经加载所有数据之和。比如：第一次搜索西湖返回10条数据，调用该方法后返回20条数据，其中前10条和第一次一样。
 */
-(void)loadMore;
-(void)goBack;
-(BOOL)hasMore;

-(MBPoiSearchError)querySelect:(MBItemType)type index:(NSInteger)index;
+ (Boolean)PoiEnvInitWithUrlBase:(NSString*)url rulesFilePath:(NSString*)path;
@end
